home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / OOPTUT34.ZIP / STAFFOBJ.PAS < prev    next >
Pascal/Delphi Source File  |  1993-05-31  |  1KB  |  61 lines

  1. unit staffobj;
  2.  
  3. {~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}
  4. { Unit as part of the illustration of Virtual Methods.                }
  5. {                                                                     }
  6. {  STAFFOBJ.PAS  ->  STAFFOBJ.TPU     R. Shaw     26.4.91             }
  7. {_____________________________________________________________________}
  8.  
  9. interface
  10.  
  11. uses Crt;
  12.  
  13. type
  14.  
  15. staff = object
  16.       Name : string;
  17.       constructor Init(SurName : string );
  18.       procedure script1;  virtual;        {virtual procedures which are   }
  19.       procedure script2;  virtual;        {overridden in the object junior}
  20.       procedure action1;            {static procedures which are inherited}
  21.       procedure action2;            {by the descendant object junior.     }
  22.       end;
  23.  
  24. var
  25.    LetterName : string;
  26.  
  27.  
  28. implementation
  29.  
  30. constructor staff.Init( SurName : string );
  31. begin
  32.      Name := SurName;
  33. end;
  34.  
  35. procedure staff.script1;
  36. begin
  37.      writeln( Name,
  38.          ': Please send the duplicated letters to all our customers.');
  39.      writeln( '        If you have a problem, please ask me.');
  40. end;
  41.  
  42. procedure staff.script2;
  43. begin
  44.      LetterName := 'OD';
  45.      writeln(Name,': The letter is headed ',LetterName,'.');
  46.      writeln;
  47. end;
  48.  
  49. procedure staff.action1;
  50. begin
  51.      script1;
  52. end;
  53.  
  54. procedure staff.action2;
  55. begin
  56.      script2;
  57. end;
  58.  
  59. end.
  60.  
  61. { end of listing }